package handler;

import java.util.Map;

import com.hn.wordmemo.wordstore.model.Word;

public class BaseHandler {

	// C:\\Documents and
	// Settings\\shenhao\\桌面\\学习中文系统设计\\词库\\小学英语\\北京版小学英语\\北京版《小学英语第一册》\\北京版《小学英语第一册》.xls
	//C:\Users\sh\Documents\学习中文系统设计\导入词库\初中英语\北京版初中英语\北京版《初中英语第一册》
	// "D:\\eclipse_workspace\\indigo\\shoutchinese-robot\\res\\北京版《小学英语第一册》.xls";
	//C:\Users\sh\Documents\学习中文系统设计\导入词库\小学英语\北京版小学英语\北京版《小学英语第三册》
//启蒙\北京启蒙\1
	private static String excelFile = "C:\\Users\\sh\\Documents\\学习中文系统设计\\导入词库\\小学英语\\北京版小学英语\\北京版《小学英语第三册》\\北京版《小学英语第三册》.xls";

	public static String HEAD_CHINESE = "中文";
	public static String HEAD_PINYING = "拼音";
	public static String HEAD_ENGLISH = "英文";
	public static String HEAD_OTHER_TRANS = "其他解释";
	public static String HEAD_CHINESE_SENTANCE1 = "中文例句1";
	public static String HEAD_ENGLISH_SENTANCE1 = "英文例句1";
	public static String HEAD_CHINESE_SENTANCE2 = "中文例句2";
	public static String HEAD_ENGLISH_SENTANCE2 = "英文例句2";
	public static String HEAD_CHINESE_SENTANCE3 = "中文例句3";
	public static String HEAD_ENGLISH_SENTANCE3 = "英文例句3";

	/**
	 * 工作流开始
	 */
	private void startWorkFlow() {

//		BaseHandler.excelFile = "C:\\Documents and Settings\\shenhao\\桌面\\学习中文系统设计\\导入词库\\北京启蒙\\6\\北京启蒙6.xls";

		System.out.println("开始执行。。。。。。");

		// 删除重复文字
		DeleteRepeatWordHandler dwh = new DeleteRepeatWordHandler();
		dwh.startWork();

		// 其他翻译
		OtherTransHandler oth = new OtherTransHandler();
		oth.startWork();

		// 拼音
		PinyingHandler ph = new PinyingHandler();
		ph.startWork();

		// 句子
		SentanceHandler sh = new SentanceHandler();
		sh.startWork();

		// 语音
		VoiceHandler vh = new VoiceHandler();
//		vh.openProxy();
		vh.startWork();

		System.out.println("全部执行完毕。。。。。。");
	}

	public BaseHandler() {
		// 代理
		// System.getProperties().put("proxySet", "true");
		// System.getProperties().put("proxyHost", "127.0.0.1");
		// System.getProperties().put("proxyPort", "808");
		// System.out.println("进入代理");
	}

	public void openProxy() {
		// 代理
		System.getProperties().put("proxySet", "true");
		System.getProperties().put("proxyHost", "127.0.0.1");
		System.getProperties().put("proxyPort", "808");
		System.out.println("进入代理");
	}

	public static void main(String[] args) {
		BaseHandler bh = new BaseHandler();
		bh.startWorkFlow();
	}

	public void startWork() {

	}

	public static String getExcelFile() {
		return excelFile;
	}

	public Word getWordByExcelCell(String bookId, Map map) {
		if (map != null) {
			Word word = new Word();
			word.setBookId(bookId);
			word.setChinese((String) map.get(HEAD_CHINESE));
			word.setEnglish((String) map.get(HEAD_ENGLISH));
			word.setOthertrans((String) map.get(HEAD_OTHER_TRANS));
			word.setPinyin((String) map.get(HEAD_PINYING));
			word.setSentenceChinese1((String) map.get(HEAD_CHINESE_SENTANCE1));
			word.setSentenceChinese2((String) map.get(HEAD_CHINESE_SENTANCE2));
			word.setSentenceChinese3((String) map.get(HEAD_CHINESE_SENTANCE3));
			word.setSentenceEnglish1((String) map.get(HEAD_ENGLISH_SENTANCE1));
			word.setSentenceEnglish2((String) map.get(HEAD_ENGLISH_SENTANCE2));
			word.setSentenceEnglish3((String) map.get(HEAD_ENGLISH_SENTANCE3));
			return word;
		}

		return null;
	}

}
